<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>融资报价维护</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<style>
.error{
	color:red;
}
</style>
<body class="iframeBody">
	<div class="Wrapper">
		<div id="pageInTab" class="pageInTab">
			<form id="scm_bsc_info_form">
				<div class="fieldset1 tabel_col tabel_col_s clearFix">
					<div class="caption">
						<span class="title">报价基础信息 </span>
					</div>
					<div class="fieldBox col_50">
						<div class="label">报价名称</div>
						<div class="field">
							<span name="fncScmNm" id="fncScmNm" >${bscinfo.fncScmNm}</span>							
							<input type="hidden" id="fncScmId" name="fncScmId" value="${fncScmId}">
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">融资机构名称</div>
						<div class="field">
							<span name="fncInsNm" id="fncInsNm" >${fncInsNm}</span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">授信名称</div>
						<div class="field">
							<span name="crNm" id="crNm" >${crNm}</span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">产品名称</div>
						<div class="field">
							<span name="pdNm" id="pdNm" >${pdNm}</span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">计划封包日</div>
						<div class="field">
							<input type="hidden" name="hstdt" id="hstdt" value="${bscinfo.stdt}">
							<input type="hidden" name="heddt" id="heddt" value="${bscinfo.eddt}">
							<span name="stdt" id="stdt" ></span>
								&nbsp;&nbsp; --- &nbsp;&nbsp;
							<span name="eddt" id="eddt" ></span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">还款类别</div>
						<div class="field">
							<span name="rePyTpCdDes" id="rePyTpCdDes" >
								<c:forEach items="${rePyTpCdLst}" var="item">
		                       		<c:choose>
			                       		<c:when test="${item.key == bscinfo.repyTp}">
			                    			<span>${item.value}</span>
			                       		</c:when>
		                       		</c:choose>
		                        </c:forEach>
							</span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">业务类别</div>
						<div class="field">
							<span name="busType" id="busType" >
		                        <c:forEach items="${busTypeLst}" var="item">
		                       		<c:choose>
			                       		<c:when test="${item.key == bscinfo.busType}">
			                    			<span>${item.value}</span>
			                       		</c:when>
		                       		</c:choose>
		                        </c:forEach>
							</span>
						</div>
					</div>
				</div>
				
				<div class="fieldset1 tabel_col tabel_col_s clearFix">
					<div class="caption">
						<span class="title">报价信息 </span>
					</div>
					<div class="fieldBox col_50">
						<div class="label">融资基数</div>
						<div class="field">
							<span name="fncCrdnltDes" id="fncCrdnltDes" >	
		                        <c:forEach items="${fncCrdnltCdLst}" var="item">
		                       		<c:choose>
			                       		<c:when test="${item.key == bscinfo.fncCrdnlt}">
			                    			<span>${item.value}</span>
			                       		</c:when>
		                       		</c:choose>
		                        </c:forEach>
							</span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">打折率(%)</div>
						<div class="field">
							<span name="dcnRate" id="dcnRate" >${bscinfo.dcnRate}</span>
						</div>
					</div>
					
					<div class="fieldBox col_50">
						<div class="label">融资期限(月)</div>
						<div class="field">
							<span name="fncTrm" id="fncTrm" >${bscinfo.fncTrm}</span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">是否涉及境外</div>
						<input id="wthrSupAbrVal" name="wthrSupAbrVal" type="hidden" value="${bscinfo.wthrSupAbr}">
						<div class="field">
							<span name="wthrSupAbrDes" id="wthrSupAbrDes" >    
		                        <c:forEach items="${searchWthrKVList}" var="item">
		                       		<c:choose>
			                       		<c:when test="${item.key == bscinfo.wthrSupAbr}">
			                    			<span>${item.value}</span>
			                       		</c:when>
		                       		</c:choose>
		                        </c:forEach>       
							</span>
						</div>
					</div>
					<div class="fieldBox col_50" id="s1">
						<div class="label">利率基准(%)</div>
						<div class="field">
							<span name="irtBs" id="irtBs" >${bscinfo.irtBs}</span>
						</div>
					</div>
					<div class="fieldBox col_50" id="s3">
						<div class="label">报价利率(%)</div>
						<div class="field">
							<span name="scmIntrt" id="scmIntrt" >${bscinfo.scmIntrt}</span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">利率是否浮动</div>
						<input id="irtTpcdVal" name="irtTpcdVal" type="hidden" value="${bscinfo.irtTpcd}">
						<div class="field">
							<span name="irtTpcdDes" id="irtTpcdDes" >    
		                        <c:forEach items="${searchWthrKVList}" var="item">
		                       		<c:choose>
			                       		<c:when test="${item.key == bscinfo.irtTpcd}">
			                    			<span>${item.value}</span>
			                       		</c:when>
		                       		</c:choose>
		                        </c:forEach>       
							</span>
						</div>
					</div>
					<div class="fieldBox col_50" title="intrtMtdcd">
						<div class="label">利率上浮方式</div>
						<div class="field">
		                    <span name="intrtMtdcd" id="intrtMtdcd">
		                       	<c:forEach items="${intrtMtdcdLst}" var="item">
		                        	<c:choose>
			                       		<c:when test="${item.key == bscinfo.intrtMtdcd}">
			                    			<span>${item.value}</span>
			                       		</c:when>
		                       		</c:choose>
		                        </c:forEach>
		                    </span>
						</div>
					</div>
					<div class="fieldBox col_50" id="s2">
						<div class="label">基准上浮比例(%)</div>
						<div class="field">
							<span name="bsFlotupRto" id="bsFlotupRto" >${bscinfo.bsFlotupRto}</span>
						</div>
					</div>
					<div class="fieldBox col_50" title="prymMtd">
						<div class="label">调息方式</div>
						<div class="field">						
							<span name="prymMtdDes" id="prymMtdDes" >   
		                        <c:forEach items="${prymMtdLst}" var="item">
		                       		<c:choose>
			                       		<c:when test="${item.key == bscinfo.prymMtd}">
			                    			<span>${item.value}</span>
			                       		</c:when>
		                       		</c:choose>
		                        </c:forEach>  
							</span>
						</div>
					</div>
				</div>	
				<!-- 担保信息  start  -->
				<div class="fieldset1 tabel_col tabel_col_s clearFix">
					<div class="caption">
						<span class="title">担保信息 </span>
					</div>
					<div class="fieldBox col_50">
						<div class="label">是否担保</div>
						<div class="field">
	                    	<c:forEach items="${sysYNList}" var="sysyn">
	                    	  <c:choose>
		                       		<c:when test="${sysyn.key == bscinfo.isGuarantee}">
		                        		${sysyn.value}
		                       		</c:when>
	                       		</c:choose>
	                    	</c:forEach>
		                </div>
		             </div>
		             <div class="fieldBox col_50">
						<div class="label">担保主体</div>
						<div class="field">
		                    <input name="guaranteeBody" id="guaranteeBody" data-value="${bscinfo.guaranteeBody}"    ltype="combobox" >
		                </div>
		             </div>
		            <div class="fieldBox col_50">
						<div class="label">担保开始日</div>
						<div class="field">
		                   ${bscinfo.guaranteeStart}
		                </div>
		             </div>
		            <div class="fieldBox col_50">
						<div class="label">担保到期日</div>
						<div class="field">
		                    ${bscinfo.guaranteeEnd}
		                </div>
		             </div>
		           <div class="fieldBox col_100">
						<div class="label">担保主体备注</div>
						<div class="field">
		                    ${bscinfo.guaranteeRemark}
		                </div>
		           </div>
				</div>
				<!-- 担保信息  end -->
				<div class="fieldset1 tabel_col tabel_col_s clearFix">
					<div class="caption">
						<span class="title">计费信息 </span>
					</div>
					<div class="fieldBox col_100">
							<div id="cost1" class="sq-grid">
							</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">方案XIRR(%)</div>
						<div class="field">
							<span name="irr" id="irr" >${bscinfo.irr}</span>
						</div>
					</div>
				</div>
				<div class="fieldset1 tabel_col tabel_col_s clearFix" id="abdform">
					<div class="caption">
						<span class="title">境外成本</span>
					</div>
					<div class="fieldBox col_50">
						<div class="label">是否存在汇率风险</div>
						<div class="field">
							<span name="exstExrtRskDes" id="exstExrtRskDes" >    
		                        <c:forEach items="${searchWthrKVList}" var="item">
		                       		<c:choose>
			                       		<c:when test="${item.key == bscinfo.exstExrtRsk}">
			                    			<span>${item.value}</span>
			                       		</c:when>
		                       		</c:choose>
		                        </c:forEach>       
							</span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">是否存在利率风险</div>
						<div class="field">
							<span name="exstIntrtRskDes" id="exstIntrtRskDes" >    
		                        <c:forEach items="${searchWthrKVList}" var="item">
		                       		<c:choose>
			                       		<c:when test="${item.key == bscinfo.exstIntrtRsk}">
			                    			<span>${item.value}</span>
			                       		</c:when>
		                       		</c:choose>
		                        </c:forEach>       
							</span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">汇率风险承包方</div>
						<div class="field">
							<span name="exrtRskCntr" id="exrtRskCntr" >${bscinfo.exrtRskCntr}</span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">利率风险承包方</div>
						<div class="field">
							<span name="intrtRskCntr" id="intrtRskCntr" >${bscinfo.intrtRskCntr}</span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">是否承做汇率掉期</div>
						<div class="field">
							<span name="cmtExrtSwpDes" id="cmtExrtSwpDes" >    
		                        <c:forEach items="${searchWthrKVList}" var="item">
		                       		<c:choose>
			                       		<c:when test="${item.key == bscinfo.cmtExrtSwp}">
			                    			<span>${item.value}</span>
			                       		</c:when>
		                       		</c:choose>
		                        </c:forEach>       
							</span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">是否承做利率掉期</div>
						<div class="field">
							<span name="cmtIntrtSwpDes" id="cmtIntrtSwpDes" >    
		                        <c:forEach items="${searchWthrKVList}" var="item">
		                       		<c:choose>
			                       		<c:when test="${item.key == bscinfo.cmtIntrtSwp}">
			                    			<span>${item.value}</span>
			                       		</c:when>
		                       		</c:choose>
		                        </c:forEach>       
							</span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">汇率掉期银行</div>
						<div class="field">
							<span name="exrtSwpBnk" id="exrtSwpBnk" >${bscinfo.exrtSwpBnk}</span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">利率掉期银行</div>
						<div class="field">
							<span name="intrtSwpBnk" id="intrtSwpBnk" >${bscinfo.intrtSwpBnk}</span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">汇率掉期费率(%)</div>
						<div class="field">
							<span name="exrtSwpFeert" id="exrtSwpFeert" >${bscinfo.exrtSwpFeert}</span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">利率掉期费率(%)</div>
						<div class="field">
							<span name="intrtSwpFeert" id="intrtSwpFeert" >${bscinfo.intrtSwpFeert}</span>
						</div>
					</div>					
				</div>	
				
				<div class="fieldset1 tabel_col tabel_col_s clearFix">
					<div class="fieldBox col_100">
						<div class="label">备注</div>
						<div class="field">
                			<textarea class="l-textarea" id="rmrk" style="width:100%" disabled="disabled">${bscinfo.rmrk}</textarea>
						</div>
					</div>
				</div>			
			</form>
		</div>
	</div>

	<script type="text/javascript">
	//add 保证金使用方式  by gengchunlan 20180626
	var mrgnUseMtdJSON = [];
	<c:if test="${not empty mrgnUseMtdJSON}"> mrgnUseMtdJSON = ${mrgnUseMtdJSON}; </c:if>
	
		$(function () {
			//REQ-15103  担保主体多选
			$("#guaranteeBody").ligerComboBox({ isShowCheckBox: true, isMultiSelect: true,
		     	   data: ${guaranteeBodyLst},
		     	  readonly: true, 
		            slide: false,
		            valueField: 'key', textField: 'value',
		            valueFieldID: 'guaranteeBody'
		      }); 
			$("#guaranteeBody").ligerComboBox()._setWidth('320');
			
			
			f_initCostData1();
			f_initPlanDate();
			initIrtForm();
			initAbroadForm();
		});
		
		function f_initPlanDate(){
			console.log("f_initPlanDate");
			var stdt = $("#hstdt").val();
			var eddt = $("#heddt").val();
			var fstdt = getFormattedDate(stdt);
			var feddt = getFormattedDate(eddt);
			$("#stdt").html(fstdt);
			$("#eddt").html(feddt);
			
		}
		
		function getFormattedDate(date){
			if(date == null || date == ""){
				return date;
			}
 			var fdate = new Date(date);
			var rdate = DateUtils.formatDate(fdate, DateUtils.YYYY_MM_DD);
			return rdate;
		}
		
	    function f_initCostData1()
	    { 
			var fncScmId = $("#fncScmId").val();
	    	$("#cost1").ligerGrid({
			    	url: '<%=path%>/rfbase/scmbaseinfo/initChrgList.do?fncScmId='+fncScmId,
			    	method : 'get',
	                columns: [
		                { display: '费用名称', width: 150, name: 'costNm',type:'text',
		                    editor: { type: 'text' }
		                },
		                { display: '是否保证金', width: 100, name: 'mrgnIs',type:'text',
			                  editor: { type: 'select', 
										data: [
						                    { value: '否', key: '0' },
						                    { value: '是', key: '1' }
						                ],
										valueField: 'key', textField: 'value' },
		                    	render: function (item)
			                    {
			                        if (parseInt(item.mrgnIs) == 1) return '是';
			                        return '否';
			                    }
			            },
			            { display: '保证金到期处理方式', name: 'mrgnUseMtd', minWidth: 150 ,enabledSort:true,
			            	       validate:{required:true,minlength:1},
			            	editor: 
			            	 {
			                    type: 'select',
			                    data: mrgnUseMtdJSON,
			                    isMultiSelect: true,isShowCheckBox: true,
			                    valueField: 'key',
			                    textField: 'value'
					          },
				                valueField: 'mrgnUseMtd',
				                textField: 'mrgnUseMtdDes',
				                render: function (item) {
				                	for(var p in mrgnUseMtdJSON){
			                			if(mrgnUseMtdJSON[p].key==item.mrgnUseMtd){
			                				return mrgnUseMtdJSON[p].value;
			                			}
				                	}
				                }
			            },
		                { display: '费用比例(%)', width: 150, name: 'costPct',type:'float',
		                    editor: { type: 'float' }
		                },
		                { display: '费用金额', name: 'costAmt', width: 150, type: 'float', editor: { type: 'float'} }, 
	                { display: '是否计入首付款', name: 'costInTpCd',width: 150,
	                    editor: { type: 'text' },
	                    render: function (item)
	                    {
	                        if (parseInt(item.costInTpCd) == 1) return '首付款';
	                        if (parseInt(item.costInTpCd) == 2) return '分期付款';
	                        if (parseInt(item.costInTpCd) == 3) return '一次性付款'; 
	                        return '分期付款';
	                    }
	                },
	                { display: '首付款是否坐扣', name: 'wthrDdct',width: 150,
	                    editor: { type: 'select', 
									data: [
					                    { value: '否', key: '0' },
					                    { value: '是', key: '1' },
					                    { value: '默认已付', key: '2' }
					                ],
									valueField: 'key', textField: 'value' },
	                    render: function (item)
	                    {
	                        if (parseInt(item.wthrDdct) == 1) return '是';
	                        if (parseInt(item.wthrDdct) == 2) return '默认已付';
	                        return '否';
	                    }
	                },
	                { display: '预计付款时间', name: 'prePayDate', type: 'date',render:renderDate,  editor: { type: 'date' } },
	                { display: '备注', name: 'rmrk', isSort: false,
	                    editor: { type: 'text' }
	                } 
	                ],
	                onSelectRow: function (rowdata, rowindex)
	                {
	                    $("#txtrowindex").val(rowindex);
	                },
	                enabledEdit: false, clickToEdit: false, isScroll: false, 
	                width: '100%',
	    	        root:'Rows',
	    	        record:'Total',
	    	        hideLoadButton : true,
	    	        width: '100%',
	    	        height:'100%',
	    	        heightDiff:-2,
	    	        checkbox:true,
	    	        rownumbers:true
	            }); 	    
	    }

    	//格式化时间
    	function renderDate(rowdata, index, value){
    		var dateStr = "";
    		if(null != value){
    			var date = new Date(value);
    			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
    		}
    		return dateStr;
    	}
    	
        function initIrtForm(){
        	var irtTpcd = $("#irtTpcdVal").val();
        	if(irtTpcd=="1"){
        		showIrtForm();
        	}
        	if(irtTpcd=="0"){
        		hideIrtForm();
        	}
        }
        
        function showIrtForm(){
        	$("#s2").show();
        	$("[title=prymMtd]").show();
        	$("[title=intrtMtdcd]").show();
        }
        
        function hideIrtForm(){
        	$("#s2").hide();
        	$("[title=prymMtd]").hide();
        	$("[title=intrtMtdcd]").hide();
        }
        
        function initAbroadForm(){
        	var wthrSupAbr = $("#wthrSupAbrVal").val();
        	if(wthrSupAbr=="1"){
        		showAbroadForm();
        	}
        	if(wthrSupAbr=="0"){
        		hideAbroadForm();
        	}
        }
        
        function showAbroadForm(){
			$("#abdform").show();
        }
        
        function hideAbroadForm(){
			$("#abdform").hide();
        }
	</script>
</body>
</html>